package com.annotation.service.impl;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.annotation.dao.AnnotationDao;
import com.annotation.service.AnnotationService;
@Service
@Scope("prototype")//这里的Scope和xml文件的用法一致
public class AnnotationServiceImpl implements AnnotationService {
//	@Autowired(required=false)//找不到匹配的bean不报错
	@Resource
	private AnnotationDao ad;
	@Override
	public void p() {
		System.out.println("Service注解测试"+this.hashCode());
		ad.p();//加注解@Autowired就可以将dao注入到service中，同样在setter方法上，构造方法上，都可以注入成功，而不需要在xml中配置
	}
}
